package top.kaoshanji.p1ch03a;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.nio.ByteBuffer;
import java.nio.ByteOrder;

/**
 * 代码清单 p1ch03a-04：字节缓冲区的字节顺序
 * author kaoshanji
 * ^_^
 * create time 2025/1/5 19:49
 */
public class ByteBufferExample02 {

    private static final Logger logger = LogManager.getLogger(ByteBufferExample02.class);

    public static void main(String[] args) {
        logger.info("...代码清单 p1ch03a-04：字节缓冲区的字节顺序...");

        ByteBuffer buffer = ByteBuffer.allocate(4);
        buffer.putInt(1);
        buffer.order(ByteOrder.LITTLE_ENDIAN); // 小端表示

        System.out.println(buffer.getInt(0));

    }

}
